<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><#include "/common/elibs.html"></head><body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="${request.contextPath}/index">首页</a>
        <a href="#">添加班组风采</a>
        <a>
          <cite>列表</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
      <i class="layui-icon" style="line-height:30px">ဂ</i></a>
  </div>
<div class="x-body">

    <div class="layui-row">
        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-sm" lay-event="add" id="add" onclick="showMsg()">
                    <i class="layui-icon"></i>添加班组风采</button>
            </div>
        </script>
        <table class="layui-hide" id="test" lay-filter="test"></table>

      <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
      </script>
    </div>
</div>
<script>
    isToken();
      layui.use('table', function(){
          var table = layui.table;
          table.render({
              elem: '#test'
              ,url: path+'/pc/proclamation/getProclamationList'
              ,toolbar: '#toolbarDemo'
              ,title: '班组风采'
              ,headers:{'X-USER-TOKEN':localStorage.getItem("token")}
              ,where:{'type' : 1}
              ,cols: [[
                  {type: 'checkbox', fixed: 'left'}
                  ,{field:'newsId',type:'numbers', title:'ID', width:80, fixed: 'left' }
              ,{field:'title', title:'公告栏名称', width:200 }
              ,{field:'filePath', title:'公告栏图片', width:100}
              ,{field:'createTime', title:'创建时间', width:220}
              ,{fixed: 'right', title:'操作', toolbar: '#barDemo'}
          ]]
              ,request: {
                  pageName: 'currentPage' //页码的参数名称，默认：page
              }
              , parseData: function (res) { //res 即为原始返回的数据
                  return {
                      "code": res.code, //解析接口状态
                      "msg": res.message, //解析提示文本
                      "count": res.data.totalResult, //解析数据长度
                      "data": res.data.data //解析数据列表
                  }
              }
              ,page: true
              ,limit:10
              ,id: 'testReload'
      });
          var $ = layui.$, active = {reload: function(){
                  var tcaParentsId = $("#tcaParentsId").val();
                  var tcaName =  $("#tcaName").val();
                  if(tcaParentsId == "" && tcaName == ""){
                      return;
                  }
                  table.reload('testReload',{
                      where: { //设定异步数据接口的额外参数，任意设
                          tcaParentsId: tcaParentsId
                          ,tcaName: tcaName
                      }
                      ,page: {
                          curr: 1 //重新从第 1 页开始
                      }
                  }); //重载表格
           }}
          $('#sreach').on('click', function(){
              var type = $(this).data('type');
              active[type] ? active[type].call(this) : '';
          });//监听行工具事件
          table.on('tool(test)', function(obj){
              var data = obj.data;
              //console.log(obj)
              if(obj.event === 'del'){
                  layer.confirm('真的删除行么', function(index){
                      var params = {
                          idProclamation : data.idProclamation
                      }
                      console.log(params);
                      if(true){
                          $.ajax({
                              url: path +'/pc/proclamation/delProclamation',
                              type: 'post',
                              // contentType : 'application/json',
                              // processData : false,
                              // dataType: 'json',
                              data: params,
                              success: function(datas) {
                                  if(datas.code != 0){
                                      layer.open({
                                          title: '提示信息'
                                          ,content: datas.message
                                      });
                                  }else{
                                      $(".layui-form-checked").not('.header').parents('tr').remove();
                                      layer.msg('删除成功', {icon: 1});
                                      obj.del();
                                      layer.close(index);
                                      console.log("success !");
                                  }
                              },
                              traditional:true
                          });
                      }
                  });
              } else if(obj.event === 'edit'){
                  window.location.href = '${request.contextPath}/modules/elegance/edit.html?id='+obj.data.idProclamation;
              }
          });});
      layui.use('layer', function(){
          var layer = layui.layer;
          $(document).on('click','#add',function(){
              if(true){ //查看
                  window.location.href=path+"/modules/elegance/add.html";
              }
          });
      });
    </script></body></html>
<script>
        function showMsg() {
            window.location.href = path + "/modules/elegance/add.html";
        }
</script>